home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / old-stream / PlotFile.cc < prev    next >
C/C++ Source or Header  |  1992-01-17  |  4KB  |  182 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988, 1992 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19. #ifdef __GNUG__
  20. #pragma implementation
  21. #endif
  22. #include <PlotFile.h>
  23.  
  24. /*
  25.  PlotFile implementation module
  26. */
  27.  
  28.  
  29. PlotFile:: PlotFile() {}
  30. PlotFile::~PlotFile() {}
  31.  
  32.  
  33. PlotFile::PlotFile(const char* filename,  io_mode m,  access_mode a) 
  34. :(filename, m, a) {}
  35.  
  36. PlotFile::PlotFile(const char* filename)
  37. :(filename, io_writeonly, a_create) {}
  38.  
  39. PlotFile::PlotFile(const char* filename,  const char* m)
  40. :(filename, m) {}
  41.  
  42. PlotFile::PlotFile(int filedesc, const io_mode m)
  43. :(filedesc, m) {}
  44.  
  45. PlotFile::PlotFile(FILE* fileptr)
  46. :(fileptr) {}
  47.  
  48. PlotFile::operator void*()
  49.   return (state & (_bad|_fail))? 0 : this ; 
  50. }
  51.  
  52.  
  53. PlotFile& PlotFile::open(const char* filename,
  54.               io_mode m,  access_mode a)
  55. {
  56.  File::open(filename, m, a); return *this; 
  57. }
  58.  
  59. PlotFile& PlotFile::open(const char* filename, const char* m)
  60. {
  61.  File::open(filename, m); return *this; 
  62. }
  63.  
  64. PlotFile& PlotFile::open(int  filedesc,  io_mode m)
  65. {
  66.  File::open(filedesc, m); return *this; 
  67. }
  68.  
  69. PlotFile& PlotFile::open(FILE* fileptr)
  70. {
  71.  File::open(fileptr); return *this; 
  72. }
  73.  
  74. PlotFile& PlotFile::setbuf(const int buffer_kind)
  75. {
  76.  File::setbuf(buffer_kind); return *this;
  77. }
  78.  
  79. PlotFile& PlotFile::setbuf(const int size, char* buf)
  80. {
  81.   File::setbuf(size, buf); return *this;
  82. }
  83.  
  84.  
  85. PlotFile& PlotFile:: cmd(char c)
  86.   File::put(c); 
  87.   return *this; 
  88. }
  89.  
  90. PlotFile& PlotFile:: operator<<(const int x)
  91. #if defined(convex)
  92.   File::put((char)(x>>8)); 
  93.   File::put((char)(x&0377)); 
  94. #else
  95.   File::put((char)(x&0377)); 
  96.   File::put((char)(x>>8)); 
  97. #endif
  98.   return *this; 
  99. }
  100.  
  101. PlotFile& PlotFile:: operator<<(const char *s)
  102.   File::put(s); 
  103.   return *this;
  104. }
  105.  
  106.  
  107. PlotFile& PlotFile:: arc(const int xi, const int yi,
  108.              const int x0, const int y0,
  109.              const int x1, const int y1)
  110.   return cmd('a') << xi << yi << x0 << y0 << x1 << y1; 
  111. }
  112.  
  113.  
  114. PlotFile& PlotFile:: box(const int x0, const int y0,
  115.              const int x1, const int y1)
  116.   line(x0, y0, x0, y1);
  117.   line(x0, y1, x1, y1);
  118.   line(x1, y1, x1, y0);
  119.   return line(x1, y0, x0, y0);
  120. }
  121.  
  122. PlotFile& PlotFile:: circle(const int x, const int y, const int r)
  123.   return cmd('c') << x << y << r; 
  124. }
  125.  
  126. PlotFile& PlotFile:: cont(const int xi, const int yi)
  127.   return cmd('n') << xi << yi;
  128. }
  129.  
  130. PlotFile& PlotFile:: dot(const int xi, const int yi, const int dx,
  131.              int n, const int* pat)
  132.   cmd('d') << xi << yi << dx << n;
  133.   while (n-- > 0) *this << *pat++;
  134.   return *this; 
  135. }
  136.  
  137. PlotFile& PlotFile:: erase()
  138.   return cmd('e'); 
  139. }
  140.  
  141. PlotFile& PlotFile:: label(const char* s)
  142.   return cmd('t') << s << "\n"; 
  143. }
  144.  
  145. PlotFile& PlotFile:: line(const int x0, const int y0,
  146.               const int x1, const int y1)
  147.   return cmd('l') << x0 << y0 << x1 << y1; 
  148. }
  149.  
  150. PlotFile& PlotFile:: linemod(const char* s)
  151.   return cmd('f') << s << "\n"; 
  152. }
  153.  
  154. PlotFile& PlotFile:: move(const int xi, const int yi)
  155.   return cmd('m') << xi << yi;
  156. }
  157.  
  158. PlotFile& PlotFile:: point(const int xi, const int yi)
  159.   return cmd('p') << xi << yi; 
  160. }
  161.  
  162. PlotFile& PlotFile:: space(const int x0, const int y0,
  163.                const int x1, const int y1)
  164.   return cmd('s') << x0 << y0 << x1 << y1; 
  165. }
  166.